package com.gewu.pm.ui.adapter.customer;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.gewu.pm.R;
import com.gewu.pm.app.AppAdapter;

/**
 * 业务员详情 - 配送商列表适配器
 */
public class SalespersonDeliveryAdapter extends AppAdapter<String> {

    public SalespersonDeliveryAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new DeliveryViewHolder();
    }

    private final class DeliveryViewHolder extends AppAdapter<?>.ViewHolder {

        private final TextView mDeliveryNameView;
        private final TextView mVehicleCodeView;
        private final TextView mSalespersonView;
        private final TextView mSalesAreaView;
        private final TextView mDepartmentView;

        private DeliveryViewHolder() {
            super(R.layout.salesperson_delivery_item);
            mDeliveryNameView = findViewById(R.id.tv_delivery_name);
            mVehicleCodeView = findViewById(R.id.tv_vehicle_code);
            mSalespersonView = findViewById(R.id.tv_salesperson);
            mSalesAreaView = findViewById(R.id.tv_sales_area);
            mDepartmentView = findViewById(R.id.tv_department);
        }

        @Override
        public void onBindView(int position) {
            String deliveryName = getItem(position);
            
            // 设置配送商名称
            mDeliveryNameView.setText(deliveryName);
            
            // TODO: 后期使用完整Bean对象替换
            // 当前显示测试数据
            mVehicleCodeView.setText("1978A");
            mSalespersonView.setText("震辉");
            mSalesAreaView.setText("杭州-滨江");
            mDepartmentView.setText("销售部");
        }
    }
}

